package com.esri.core.map;

import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public abstract class LayerSource {
    private LayerType a;

    public abstract String toJson() throws Exception;

    /* loaded from: classes.dex */
    public enum LayerType {
        MAPLAYER("mapLayer"),
        DATALAYER("dataLayer");
        
        String a;

        static LayerType a(String str) {
            return str.equalsIgnoreCase("mapLayer") ? MAPLAYER : str.equalsIgnoreCase("dataLayer") ? DATALAYER : null;
        }

        LayerType(String str) {
            this.a = str;
        }

        @Override // java.lang.Enum
        public String toString() {
            return this.a;
        }
    }

    public LayerType getType() {
        return this.a;
    }

    public void a(LayerType layerType) {
        this.a = layerType;
    }

    public static LayerSource fromJson(JsonParser jsonParser) throws Exception {
        LayerSource layerSource = null;
        if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
            return null;
        }
        int i = -1;
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String currentName = jsonParser.getCurrentName();
            jsonParser.nextToken();
            if ("type".equals(currentName)) {
                if (LayerType.a(jsonParser.getText()) == LayerType.MAPLAYER) {
                    layerSource = new LayerMapSource(-1);
                } else {
                    layerSource = new LayerDataSource();
                }
            } else if ("mapLayerId".equals(currentName)) {
                i = jsonParser.getIntValue();
            }
        }
        if (layerSource != null && (layerSource instanceof LayerMapSource)) {
            ((LayerMapSource) layerSource).setLayerId(i);
        }
        return layerSource;
    }
}
